/**
 *  Copyright (c)  2010  Angel Ortiz.
 *  Permission is granted to copy, distribute and/or modify this document
 *  under the terms of the GNU Free Documentation License, Version 1.3
 *  or any later version published by the Free Software Foundation;
 *  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 *  A copy of the license is included in the section entitled "GNU
 *  Free Documentation License". 
 */

package view;

import java.awt.Dimension;
import javax.swing.JLayeredPane;

import data.Images;
import data.OverviewData;

import main.KeyboardListener;

/**
 * @author(s) Angel Ortiz, Leszek Karcz
 * @date 03/19/2010
 * 
 */
public class Overview extends JLayeredPane {

	private static final long serialVersionUID = -6354999183691075462L;
	private OverviewBackgroundGUI backGUI;
	private UnitOverview unitGUI;
	private StructureOverview structGUI;
	private ArmyOverview armyGUI;
	private int GUI_MODE = 0; // default
	private int width;
	private int height;

	public Overview(Images images, OverviewData data) {

		this.width = 1024;
		this.height = 600;
		this.setPreferredSize(new Dimension(this.width, this.height));
		this.setLocation(0, 0);

		// back GUI
		this.backGUI = new OverviewBackgroundGUI(images);
		this.structGUI = new StructureOverview(data, images);
		this.armyGUI = new ArmyOverview(data, images);
		this.unitGUI = new UnitOverview(data, images);
		this.add(this.backGUI, new Integer(0));

		this.add(this.structGUI, new Integer(1));
		// this.add(this.armyGUI, new Integer(2));
		this.add(this.unitGUI, new Integer(3));

	}

	public void nextMode() {
		this.GUI_MODE++;
		if (this.GUI_MODE > 2)
			this.GUI_MODE = 0;
	}

	public void previousMode() {
		this.GUI_MODE--;
		if (this.GUI_MODE < 0)
			this.GUI_MODE = 2;
	}

	public void setMode(int mode) {
		this.GUI_MODE = mode;
	}

	public void refresh() {
		if (this.GUI_MODE == 1) {
			this.structGUI.repaint();
			this.structGUI.setVisible(true);
			this.armyGUI.setVisible(false);
			this.unitGUI.setVisible(false);
		} else if (this.GUI_MODE == 2) {
			this.armyGUI.repaint();
			this.armyGUI.setVisible(true);
			this.structGUI.setVisible(false);
			this.unitGUI.setVisible(false);
		} else {
			this.unitGUI.repaint();
			this.unitGUI.setVisible(true);
			this.structGUI.setVisible(false);
			this.armyGUI.setVisible(false);
		}
	}

}
